import moment from "./moment"

let logStorage = {
	info: (str) => {
		if(!uni.getStorageSync("w_log")){
			let time = moment().format("YYYY-MM-DD HH:mm:ss")
			uni.setStorageSync("w_log",  time + "  " + str)
		}else {
			
			let time = moment().format("YYYY-MM-DD HH:mm:ss")
			let kbTmp = uni.getStorageInfoSync().currentSize;
			
			if(kbTmp > 2000){
				uni.removeStorageSync("w_log")
				uni.setStorageSync("w_log", "\n\r" + time + "  "  + str)
			}else {
				
				let strAppend = uni.getStorageSync("w_log") + "\n\r" + time  + "  "  + str;
				uni.setStorageSync("w_log", strAppend)
			}
			
		}
	}
}

export default logStorage;